Index Out of Bounds (IOB)

Description:

IOB detects situtations where a loop iterator variable is compared with the length of one array but is used to access elements of another array. This audit can work in several modes which can be selected by the option Level of checking in the audit properties. Checks performed at a higher level include all of the checks performed at lower levels.

Level 0
Check for suspicious loop condition for array indices. The following loop conditions are considered to be suspicious:
    while i = High(array)+1 do ...
    while i <= High(array)+1 do ...
    while i > High(array) do ...
    while i >= High(array)+1 do ...
Level 1 (default)
Produce a warning if not comparing an index with the length of the array for which it is used, but instead checking it with the length of some other array:
    for i:= 0 to High(arr1) do 
        for j:= 0 to High(arr2) do 
             arr1[i] := arr2[i];
Level 2
Produce a warning if comparing an index with the length of one array while using it to access an element of another array. This condition is weaker than the one checked at level 1, because it is not required that the index is compared with the length of some other array:

Incorrect:

for i := 0 to nIterations do
begin
    sum := 0;
    for j := 0 to High(arr) do 
        sum := sum + arr[i];
end;

Correct:

for i := 0 to nIterations do
begin
    sum := 0;
    for j := 0 to High(arr) do 
        sum := sum + arr[j];
end;